<?php
require_once("database.php");
class xl_class_member extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from class_member limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from class_member";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($uid, $scid, $clid)
	{
		
		$sql = "select * from class_member where uid = '$uid', scid = '$scid', clid = '$clid'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($uid, $scid, $clid)
	{
		
		$sql = "delete from class_member where uid = '$uid', scid = '$scid', clid = '$clid'";
		$this->setQuery($sql);
		$this->query();
	}
	function them($uname)
	{
		$uname = addslashes($uname);

		$sql = "INSERT INTO class_member(uname) VALUES ('$uname')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($uid, $scid, $clid, $uname)
	{
		$uname = addslashes($uname);

		$sql ="UPDATE class_member SET uname= '$uname' WHERE uid = '$uid', scid = '$scid', clid = '$clid'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from class_member where	$uname like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>